package com.sg.hms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sg.hms.Service.EmployeeService;
import com.sg.hms.ServiceImpl.EmployeeServiceImpl;
/**
 * 
 * @author 陈良机
 *
 */
public class DelEmplController extends HttpServlet{
	EmployeeService emservice=new EmployeeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int flag=0;
		String delelId[]=req.getParameterValues("elId[]");
		int elId[]=new int[delelId.length];
		for(int i=0;i<delelId.length;i++){
			elId[i]=Integer.parseInt(delelId[i]);
			//无法删除管理员
			if(elId[i]==1||elId[i]==2||elId[i]==3||elId[i]==4||elId[i]==5||elId[i]==6){
				flag=0;
			}else{
				emservice.delEmpl(elId[i]);
				flag=1;
			}
		}
		PrintWriter pw=resp.getWriter();
		pw.write(String.valueOf(flag));
		pw.flush();
		pw.close();
	}
}
